<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="common/include :: header('请假流程列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="formId">
				<div class="select-list">
					<ul>
						<li class="select-time">
							<label>创建时间：</label>
							<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginTime"/>
							<span>-</span>
							<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
						</li>
						<li>
							状态：<select name="status" th:with="type=${@dict.getType('cpa_status')}" >
							<option value = "" >所有</option>
							<option th:each="dict : ${type}" th:text="${dict.label}" th:value="${dict.value}">所有</option>
						</select>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">

			<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:customer:add">
				<i class="fa fa-plus"></i> 发起申请
			</a>
		</div>
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table"></table>
		</div>
	</div>
</div>
<th:block th:include="common/include :: footer" />

<script th:inline="javascript">
	var statusDatas = [[${@dict.getType('cpa_status')}]];

	var prefix = ctx + "/business/leave";

	$(function() {
		var options = {
			url: prefix + "/query",
			createUrl: prefix + "/addPage",
			updateUrl: prefix + "/editPage?id={id}",
			removeUrl: prefix + "/remove",
			modalName: "请假流程",
			columns: [{
				checkbox: true
			},
				{
					field: 'id',
					visible: false
				},
				{
					field: 'name',  // ***** 注意，这种取值方式 ****
					title: '用户名称'
				},

				{
					field: 'info',
					title: '请假原因',

				},
				{
					field: 'startTime',  // ***** 注意，这种取值方式 ****
					title: '开始时间'
				},
				{
					field: 'endTime',
					title: '结束时间'
				},
				{
					field: 'autitor.userName',   //*******  注意，连表查询显示 *******
					title: '审核人名称',
				},
				{
					field: 'status',
					title: '状态',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(statusDatas, value);
					}
				},
				]
		};
		$.table.init(options);
	});

	function showProcessImgDialog(id) {
		var url = prefix + '/processImg?id=' + id;
		$.modal.open("查看流程图", url);
	}

	function cancelApply(id) {
		$.modal.confirm("确认要撤销申请吗?", function() {
			var url = prefix + "/cancelApply?id=" + id;
			$.operate.submit(url, "post", "json");
		});
	}


</script>
</body>
</html>